package com.example.study.testwaitandnotify;

/**
 * 消费者
 *
 * @author hjh
 * @create 2019-08-21 18:35
 **/
class Input extends Thread{
    Res res;
    public Input(Res res){
        this.res=res;
    }

    @Override
    public void run() {
        while (true){
            synchronized (res.getClass()){
                if(!res.flag){
                    try {
                        res.getClass().wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(res.username+","+res.sex);
                res.flag=false;
//                res.getClass().notify();
            }
        }
    }
}

